
#pragma once

#include "zAdAChar.h"
#include "zDbSection.h"

class UcDbSection;
class UcDbSectionManagerIterator;
class UcDbImpSectionManager;

class UcDbSectionManager : public UcDbObject
{
public:
    UCDB_DECLARE_MEMBERS(UcDbSectionManager);

    UCDB_PORT Ucad::ErrorStatus getSection  (const ZTCHAR* pszName,
                                             UcDbObjectId& id) const;
    UCDB_PORT Ucad::ErrorStatus getSection  (const ZTCHAR* pszName,
                                             UcDbSection*& pSecPlane,
                                             UcDb::OpenMode mode) const;
    UCDB_PORT Ucad::ErrorStatus getLiveSection(UcDbObjectId& id) const;
    UCDB_PORT Ucad::ErrorStatus getLiveSection(UcDbSection*& pSecPlane,
                                             UcDb::OpenMode mode) const;
    UCDB_PORT int   numSections             (void) const;
    UCDB_PORT Ucad::ErrorStatus newIterator (UcDbSectionManagerIterator*& pIterator) const;
    UCDB_PORT Ucad::ErrorStatus getUniqueSectionName(const ZTCHAR* pszBaseName,
                                             ZTCHAR*& pszUniqueName) const;
    UCDB_PORT virtual Ucad::ErrorStatus getClassID  (CLSID* pClsid) const;
    UCDB_PORT virtual Ucad::ErrorStatus dwgInFields (UcDbDwgFiler* pFiler);
    UCDB_PORT virtual Ucad::ErrorStatus dwgOutFields(UcDbDwgFiler* pFiler) const;
    UCDB_PORT virtual Ucad::ErrorStatus dxfInFields (UcDbDxfFiler* pFiler);
    UCDB_PORT virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* pFiler) const;

public:

    UCDB_PORT UcDbSectionManager(void);
    UCDB_PORT ~UcDbSectionManager(void);
};

class UcDbSectionManagerIterator
{
public:
    UCDB_PORT virtual ~UcDbSectionManagerIterator(void);

    UCDB_PORT void  start                   (void);
    UCDB_PORT void  step                    (void);
    UCDB_PORT bool  done                    (void) const;

    UCDB_PORT UcDbObjectId      getSection  (void) const;
    UCDB_PORT Ucad::ErrorStatus getSection  (UcDbSection*& pSecPlane,
                                             UcDb::OpenMode openMode) const;

protected:
    UCDB_PORT UcDbSectionManagerIterator(UcDbSectionManager* pMgr);

protected:
    void            *   mpImpObj;

    friend class UcDbImpSectionManager;
};
